package ezXpns.storage;

import java.util.UUID;


//@author A0088827L
class CompoundStorageListener<T> implements StorageListener<T> {
	public CompoundStorageListener(StorageListener<T>[] subHandlers) {
		this.subHandlers = subHandlers;
	}

	@Override
	public void onAdd(UUID id, T item) {
		for(int i = 0; i < subHandlers.length; ++i) {
			subHandlers[i].onAdd(id, item);
		}
	}

	@Override
	public void onRemove(UUID id, T item) {
		for(int i = 0; i < subHandlers.length; ++i) {
			subHandlers[i].onRemove(id, item);
		}	
	}

	@Override
	public void onReplace(UUID id, T oldItem, T newItem) {
		for(int i = 0; i < subHandlers.length; ++i) {
			subHandlers[i].onReplace(id, oldItem, newItem);
		}
	}

	private StorageListener<T>[] subHandlers;
}
